package com.dsteiner.widgets.client.domain;

import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.google.gwt.user.client.rpc.IsSerializable;

public class DataRequest implements IsSerializable{
	private Set<String> flags = new HashSet<String>();
	private Map<String, String> parameters = new HashMap<String, String>();
	private Map<String, BaseObject> parametersObj = new HashMap<String, BaseObject>();
	public boolean canceled;
	
	public DataRequest() {
	}
	public DataRequest(String flag) {
		addFlag(flag);
	}
	public void addFlag(String flag) {
		flags.add(flag);
	}
	public boolean contains(String flag) {
		return flags.contains(flag);
	}
	public void setCanceled(boolean canceled) {
		this.canceled = canceled;
	}
	public boolean isCanceled() {
		return canceled;
	}
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (!(obj instanceof DataRequest))
			return false;
		DataRequest other = (DataRequest) obj;
		return other.flags.equals(flags);
	}
	public Set<String> getFlags() {
		return flags;
	}
	@Override
	public int hashCode() {
		return flags.hashCode();
	}
	public void setFlags(Set<String> flags) {
		this.flags = flags;
	}
	@Override
	public String toString() {
		return flags.toString();
	}
	public void setParameter(String name, String value) {
		parameters.put(name, value);
	}
	public String getParameters(String name) {
		return parameters.get(name);
	}
	public void setParameterObj(String name, BaseObject value) {
		parametersObj.put(name, value);
	}
	public BaseObject getParameterObj(String name) {
		return parametersObj.get(name);
	}
}